package player;

import constants.Constants;

/**
 * The Class Player is responsible for player parameters as
 * time and points.
 */
public class Player {
	
	/**
	 * Instantiates a new player.
	 */
	public Player() {
		timeLeft = Constants.START_TIME;
		points = 0;
	}
	
	/**
	 * Recalculates the players time left.
	 *
	 * @param deltaTime the delta time
	 */
	public void Update(float deltaTime) {
		if (timeLeft > .0f)
			timeLeft -= deltaTime;
	}
	
	/**
	 * Adds time and points to the player.
	 *
	 * @param time the time to add
	 */
	public void AddTime(float time) {
		if (!IsDead()) {
			timeLeft += time;
			points += (int)time;
		}
	}
	
	/**
	 * Gets the time left.
	 *
	 * @return the time left
	 */
	public float GetTimeLeft() {
		return timeLeft;
	}
	
	/**
	 * Gets the points.
	 *
	 * @return the actual points
	 */
	public int GetPoints() {
		return points;
	}
	
	/**
	 * Kills the player.
	 */
	public void Kill() {
		timeLeft = .0f;
	}

	/**
	 * Checks if the player is dead.
	 *
	 * @return true, if dead
	 */
	public boolean IsDead() {
		if (timeLeft <= .0f)
			return true;
		return false;
	}
	
	private float timeLeft;
	private int points;
}
